import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'

Vue.prototype.isEmpty = function (str) {
	if ((!str || 0 === str.length)) {
		uni.showToast({
			title: '填写内容不能为空',
			icon: 'none'
		});
		return;
	}

}


// 获取上一周,本周,下一周
Vue.prototype.getWeek = function(n, type) { // 周
	let now = new Date()
	let day = now.getDay() //返回星期几的某一天;
	if (!type) {
		if (n == 1) {
			let dayNumber = day == 0 ? 0 : 7 - day
			now.setDate(now.getDate() + dayNumber + 1)
		} else if (n == -1) {
			let dayNumber = day == 0 ? 6 : day - 1
			now.setDate(now.getDate() - dayNumber - 7)
		} else {
			let dayNumber = day == 0 ? 6 : day - 1
			now.setDate(now.getDate() - dayNumber)
		}
	} else {
		if (n == 1) {
			let dayNumber = day == 0 ? 0 : 7 - day
			now.setDate(now.getDate() + dayNumber + 1 + 6) // 在周开始的日期上+6天=周结束
		} else if (n == -1) {
			let dayNumber = day == 0 ? 6 : day - 1
			now.setDate(now.getDate() - dayNumber - 7 + 6)
		} else {
			let dayNumber = day == 0 ? 0 : 7 - day
			now.setDate(now.getDate() + dayNumber)
		}
	}
	let date = now.getDate()
	let month = now.getMonth() + 1

	let s = now.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' +
		date :
		date)
	return s
//这里调用方法
	// 	this.getWeek(-1, 0), // 获取上周开始日期
	// 	this.getWeek(-1, 1), // 获取上周结束日期
	// 	this.getWeek(0, 0), // 获取本周开始日期
	// 	this.getWeek(0, 1), // 获取本周结束日期
	// 	this.getWeek(1, 0), // 获取下周开始日期
	// 	this.getWeek(1, 1), // 获取下周结束日期 
}

Vue.prototype.nowTime = Date.nowTime || function () {  
    return new Date().getTime();  
};  


const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif